import { _decorator, AnimationClip, Component, Node } from 'cc';
import State from '../../Base/State';
import { StateMachine } from '../../Base/StateMachine';
import { DIRECTION_ENUM, SHAKE_DIRECTION_ENUM } from '../../Enums';
import DirectionSubStateMachine from '../../Base/DirectionSubStateMachine';
import { ANIMATION_SPEED } from '../../Base/State';
const { ccclass, property } = _decorator;

const BASE_URL = `texture/player/attack`

@ccclass('AttackSubStateMachine')
export default class AttackSubStateMachine extends DirectionSubStateMachine {

    constructor(fsm: StateMachine) {
        super(fsm)
        this.stateMachine.set(
            DIRECTION_ENUM.TOP,
            new State(fsm, `${BASE_URL}/top`, AnimationClip.WrapMode.Normal, ANIMATION_SPEED,
                [{
                    frame: ANIMATION_SPEED * 4,//第几帧
                    func: 'onAttackShake',//回调函数
                    params: [SHAKE_DIRECTION_ENUM.TOP]//参数（方向）
                }])
        );
        this.stateMachine.set(
            DIRECTION_ENUM.LEFT,
            new State(fsm, `${BASE_URL}/left`, AnimationClip.WrapMode.Normal, ANIMATION_SPEED,
                [{
                    frame: ANIMATION_SPEED * 4,//第几帧
                    func: 'onAttackShake',//回调函数
                    params: [SHAKE_DIRECTION_ENUM.LEFT]//参数（方向）
                }])
        );
        this.stateMachine.set(
            DIRECTION_ENUM.BOTTOM,
            new State(fsm, `${BASE_URL}/bottom`, AnimationClip.WrapMode.Normal, ANIMATION_SPEED,
                [{
                    frame: ANIMATION_SPEED * 4,//第几帧
                    func: 'onAttackShake',//回调函数
                    params: [SHAKE_DIRECTION_ENUM.BOTTOM]//参数（方向）
                }])
        );
        this.stateMachine.set(
            DIRECTION_ENUM.RIGHT,
            new State(fsm, `${BASE_URL}/right`, AnimationClip.WrapMode.Normal, ANIMATION_SPEED,
                [{
                    frame: ANIMATION_SPEED * 4,//第几帧
                    func: 'onAttackShake',//回调函数
                    params: [SHAKE_DIRECTION_ENUM.RIGHT]//参数（方向）
                }])
        );
    }
}


